<template>
  <div>
    <div class="navigate-wrp">
      <div class="icon-wrp">
        <div class="png" @click="showMenu">
          <img alt="menu" src="../assets/imgs/menu.png" />
        </div>

        <span>萌通加速</span>
        <div class="png" @click="reloadPage">
          <img alt="reload" src="../assets/imgs/reload.png" />
        </div>
      </div>
    </div>

    <div class="content-body">
      <swiper
        :slides-per-view="'auto'"
        :centered-slides="true"
        :loop="true"
        :space-between="20"
        @swiper="onSwiper"
        @slideChange="onSlideChange"
      >
        <swiper-slide class="swiper-slide" v-for="(item, index) in 10" :key="index">
          <div class="content-card">
            <div class="num" :class="{ loading: loadingVisible }">
              {{ !loadingVisible ? "365" : "" }}
            </div>
            <div class="unit" :class="{ loading: loadingVisible }">
              {{ !loadingVisible ? "天数" : "" }}
            </div>
            <div class="other" :class="{ loading: loadingVisible }">
              <span v-if="!loadingVisible">剩余时间</span>
              <div class="button" v-if="!loadingVisible">续费</div>
            </div>
          </div>
        </swiper-slide>
      </swiper>
      <div class="select-wrp" @click="selectNode">
        <div class="wrp-left" v-if="!loadingVisible">
          <div class="img-wrp">
            <div class="bg-img hongkong"></div>
          </div>
          <span class="text"> [隧道]香港01</span>
        </div>
        <div class="wrp-right" v-if="!loadingVisible">
          <div class="bg-img down"></div>
        </div>
        <div
          class="show-loading"
          v-if="loadingVisible"
          :class="{ loading: loadingVisible }"
        ></div>
      </div>

      <div
        class="circle-wrp"
        :class="{ 'circle-wrp-active': connectStatus }"
        @click="actionConnect"
      >
        {{ connectStatus ? "已连接" : "即刻连接" }}
      </div>
    </div>

    <NodeList ref="nodeRef" />
    <SurfButton />
  </div>
</template>

<script>
// Import Swiper Vue.js components
import { Swiper, SwiperSlide } from "swiper/vue";
// Import Swiper styles
import "swiper/css";
import SurfButton from "../components/SurfButton.vue";
import NodeList from "../components/NodeList.vue";
export default {
  name: "SurfPage",
  components: {
    Swiper,
    SwiperSlide,
    SurfButton,
    NodeList,
  },
  data: () => ({
    menuVisible: false,
    connectStatus: false,
    loadingVisible: false,
  }),
  methods: {
    showMenu: function () {
      this.menuVisible = true;
    },
    actionConnect: function () {
      this.connectStatus = !this.connectStatus;
    },
    reloadPage: function () {
      this.loadingVisible = !this.loadingVisible;
    },
    selectNode: function () {
      this.$refs.nodeRef.visible = true;
    },
    onSwiper: function (swiper) {
      console.log(swiper);
    },
    onSlideChange: function () {
      console.log("slide change");
    },
  },
};
</script>

<style scoped>


/* navigate */
.navigate-wrp {
  box-sizing: border-box;
}
.navigate-wrp .icon-wrp {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 15px;
  line-height: 40px;
  font-size: 22px;
  font-weight: 500;
  box-sizing: border-box;
}
.navigate-wrp .icon-wrp .png {
  position: relative;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border-radius: 50%;
  padding: 5px;
}
.navigate-wrp .icon-wrp .png img {
  width: 100%;
  height: 100%;
}
.png::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  transform: translate3d(-50%, -50%, 0) scale(0, 0);
  border-radius: 50%;
  background-color: #b3aead;
  transform-origin: center;
  transition: ease-in-out 0.5s;
}

.png:hover::before {
  transform: translate3d(-50%, -50%, 0) scale(15, 15);
}

/*  content-body  */
.swiper-slide {
  z-index: 1;
  width: 60%;
  /* Center slide text vertically */
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
}
.content-card {
  width: calc(100vw - 50px);
  padding: 15px 20px 15px;
  border-radius: 20px;
  box-shadow: 2px 2px 6px #c0c0c0;
  margin: 20px auto;
  box-sizing: border-box;
  background-color: #fff;
}
.content-card .num {
  height: 34px;
  line-height: 34px;
  font-size: 32px;
  font-weight: 600;
  color: #000;
  box-sizing: border-box;
  /* overflow: hidden;   */
}
.num.loading {
  display: flex;
  width: 80px;
}
.content-card .unit {
  margin: 5px 0 0;
  height: 20px;
  line-height: 20px;
  font-size: 12px;
  color: #b7b7b7;
  box-sizing: border-box;
  overflow: hidden;
}
.unit.loading {
  display: flex;
  width: 30px;
}
.content-card .other {
  height: 40px;
  font-size: 16px;
  font-weight: 600;
  color: #000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
  overflow: hidden;
}
.other .button {
  font-size: 12px;
  color: #fff;
  background: #000;
  padding: 2px 10px;
  border-radius: 5px;
  box-sizing: border-box;
}
/* select-wrp */
.select-wrp {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 58px;
  margin: 0 auto;
  text-align: center;
  box-shadow: 0px 0px 8px #c0c0c0;
  width: calc(100vw - 50px);
  border-radius: 50px;
  padding: 0 20px;
}
.wrp-left {
  display: flex;
  align-items: center;
}
.wrp-left .img-wrp {
  /* display: inline-block; */
  height: 25px;
  width: 25px;
  margin-right: 5px;
}
.bg-img.hongkong {
  background-image: url("../assets/imgs/hongkong.png");
  border-radius: 50%;
}
.wrp-left .text {
  line-height: 50px;
  font-size: 19px;
  font-weight: bold;
}
.wrp-right {
  height: 20px;
  width: 20px;
}
.bg-img.down {
  background-image: url("../assets/imgs/down.png");
}
.show-loading {
  width: 100%;
  height: 20px;
}

/* circle-wrp */
.circle-wrp {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 50px auto;
  box-shadow: 0px 0px 8px #fc393d;
  width: 50vw;
  height: 50vw;
  border: 10px solid #fc393d;
  border-radius: 50%;
  box-sizing: border-box;
  transition: ease-in-out 0.5s;
}
.circle-wrp-active {
  border: 18px solid #0ff37b;
}
</style>
